home *** CD-ROM | disk | FTP | other *** search
- ;void grab_box(box,top_x,top_y,width,depth,color);
- ; unsigned char *box,top_x,top_y,width,depth,color;
-
- EXTRN _memory_model:byte
- EXTRN _video_buffer:word
- EXTRN _snow_protect:byte
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _grab_box
- _grab_box proc near
- push bp ;
- mov bp,sp ;set stack frame
- push di ;
- push si ;
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: push ds ;
- mov bl,_snow_protect ;grab _snow_protect
- cmp _memory_model,2 ;data near or far?
- jb L0 ;jump if near
- les di,dword ptr[bp+4] ;ES:DI pts to byte array
- add bp,2 ;inc BP since dword ptr
- jmp short L00 ;jump ahead
- L0: mov ax,ds ;shift DS to ES
- mov es,ax ;
- mov di,[bp+4] ;NEAR case
- L00: mov ax,_video_buffer ;fetch video address
- mov ds,ax ;DS points to buffer
- sub ax,ax ;
- mov al,[bp+8] ;row in AX
- dec ax ;count rows from 0
- mov dl,160 ;160 bytes per row
- mul dl ;AX times 160
- sub dx,dx ;
- mov dl,[bp+6] ;col in DX
- dec dx ;count cols from 0
- shl dx,1 ;double for attributes
- add ax,dx ;offset of topleft corner
- mov dh,[bp+10] ;width in DH
- mov dl,[bp+12] ;depth in DL
- mov ch,[bp+14] ;fill attribute
- mov cl,32 ;space char for fill
- mov bp,ax ;scrn ptr copy in BP
- mov ah,bl ;move _snow_protect
- mov bx,cx ;copy in BX
- sub cx,cx ;clear loop counter
- cld ;set direction flag
- L1: mov si,bp ;set DS:SI scrn ptr
- mov cl,dh ;count box width
- push dx ;save width,depth ctr
- L2: cmp ah,0 ;protect against snow?
- je L7 ;jump ahead if not
- mov dx,3dah ;status byte port addr
- L3: in al,dx ;get status byte
- test al,1 ;test bit
- jnz L3 ;loop till 0
- cli ;disable interrupts
- L4: in al,dx ;get status byte
- test al,1 ;test bit
- jz L4 ;loop till 1
- movsw ;transfer word to buffer
- sub si,2 ;pull back screen ptr
- L5: in al,dx ;get status byte
- test al,1 ;test bit
- jnz L5 ;loop till 0
- L6: in al,dx ;get status byte
- test al,1 ;test bit
- jz L6 ;loop till 1
- mov [si],bx ;clear cell on screen
- add si,2 ;move scrn ptr back
- jmp short L8 ;jump ahead
- L7: movsw ;monochrome: transf char
- mov [si-2],bx ;clear screen cell
- L8: loop L2 ;go do next
- pop dx ;restore width,depth ctrs
- add bp,160 ;forward ptr to next row
- dec dl ;dec depth counter
- jnz L1 ;loop if another line
- L9: sti ;reenable interrupts
- pop ds ;
- pop si ;
- pop di ;
- pop bp ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- _grab_box endp
- _TEXT ENDS
- END